import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false

//声明全局过滤器 - 可以在任意页面/组件中使用
Vue.filter("dateToStr", (time) => {
	let d = new Date(time);
	let year = d.getFullYear();
	let month = d.getMonth() + 1;
	month = month < 10 ? "0" + month : month;
	let day = d.getDate();
	day = day < 10 ? "0" + day : day;
	let hour = d.getHours();
	hour = hour < 10 ? "0" + hour : hour;
	let minute = d.getMinutes();
	minute = minute < 10 ? "0" + minute : minute;
	return `${year}-${month}-${day} ${hour}:${minute}`
})
//费用类型 => 费用名称
Vue.filter('feeTypeName', (type) => {
	let arr = ['全部类型', '水费', '电费', '燃气费', '物业', '停车', '宽带'];
	//??运算符 检测第一个表达式的值是否存在，存在就返回，不存在返回第二个表达式的值
	let typeName = arr[type] ?? '未知类型'
	return typeName;
})
//费用类型 => 费用图片
Vue.filter('feeTypeIcon', (type) => {
	let arr = ['logo2', 'shui', 'dian', 'ranqi', 'wuye', 'tingche', 'kuandai'];
	let typeIcon = arr[type] ?? 'logo2'
	return `/static/img/${typeIcon}.png`
})
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
